/*
DELIMITER $$
DROP  FUNCTION  IF  EXISTS  `sys_uuid`$$
CREATE FUNCTION `sys_uuid`() 

RETURNS varchar(32)
BEGIN
      RETURN replace(uuid(),'-','');
END $$
DELIMITER;
*/

BEGIN;

DROP TABLE IF EXISTS `ds_image`;
CREATE TABLE `ds_image` (
  id         VARCHAR(32),
  image_path VARCHAR(255),
  image_base LONGTEXT,
  created_on LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_file`;
CREATE TABLE `ds_file` (
  id         VARCHAR(32),
  file_path  VARCHAR(255),
  file_base  LONGTEXT,
  size       LONG,
  md5        VARCHAR(32),
  created_on LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_user`;
CREATE TABLE `ds_user` (
  id         VARCHAR(32),
  login_id   VARCHAR(100),
  password   VARCHAR(64),
  salt       VARCHAR(64),
  user_type  INT(2),
  last_login LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_admin`;
CREATE TABLE `ds_admin` (
  id         VARCHAR(32),
  login_id   VARCHAR(100),
  role_id    VARCHAR(32),
  user_name   VARCHAR(100),
  phone      VARCHAR(25),
  image      VARCHAR(32),
  description VARCHAR(255),
  is_delete  BOOLEAN DEFAULT '0',
  created_on LONG,
  updated_on LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_customer`;
CREATE TABLE `ds_customer` (
  id          VARCHAR(32),
  login_id    VARCHAR(200),
  nickname    VARCHAR(200),
  real_name   VARCHAR(100),
  sex         BOOLEAN,
  phone       VARCHAR(20),
  email       VARCHAR(100),
  birthday    DATE,
  image       VARCHAR(32),
  description VARCHAR(255),
  is_delete   BOOLEAN DEFAULT '0',
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_customer_address`;
CREATE TABLE `ds_customer_address` (
  id         VARCHAR(32),
  parent_id  VARCHAR(32),
  receiver VARCHAR(100),
  phone VARCHAR(21),
  postcode VARCHAR(10),
  is_default BOOLEAN,
  area_code  VARCHAR(100),
  area_name  VARCHAR(200),
  detail     VARCHAR(300),
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_root`;
CREATE TABLE `ds_root` (
  id          VARCHAR(32),
  parent_id   VARCHAR(32),
  name        VARCHAR(100),
  url         VARCHAR(200),
  type        CHAR(1) DEFAULT '0',
  seq         INT(8),
  description VARCHAR(255),
  is_delete   BOOLEAN DEFAULT '0',
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_role`;
CREATE TABLE `ds_role` (
  id          VARCHAR(32),
  role_name   VARCHAR(100),
  description VARCHAR(255),
  del         BOOLEAN DEFAULT TRUE,
  is_delete   BOOLEAN DEFAULT '0',
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_role_root`;
CREATE TABLE `ds_role_root` (
  role_id VARCHAR(32),
  root_id VARCHAR(32),
  weight  INT(2),
  FOREIGN KEY (role_id) REFERENCES `ds_role` (id),
  FOREIGN KEY (root_id) REFERENCES `ds_root` (id)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_codelist`;
CREATE TABLE `ds_codelist` (
  id        VARCHAR(32),
  book_name VARCHAR(100),
  code      VARCHAR(10),
  name      VARCHAR(200),
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_seat`;
CREATE TABLE `ds_seat` (
  id          VARCHAR(32),
  name        VARCHAR(200),
  `rows`      INT(3),
  `columns`   INT(3),
  maps        TEXT,
  legend      TEXT,
  seats       TEXT,
  unavailables VARCHAR(200),
  is_delete   BOOLEAN DEFAULT '0',
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_concert`;
CREATE TABLE `ds_concert` (
  id          VARCHAR(32),
  title       VARCHAR(100),
  poster      VARCHAR(100),
  place       VARCHAR(200),
  begin_on    VARCHAR(100),
  short_desc  VARCHAR(255),
  content     TEXT,
  type        VARCHAR(32),
  seat_type   VARCHAR(32),
  seat_map_id VARCHAR(32),
  seats       VARCHAR(255),
  status      VARCHAR(32),
  tags        varchar(255),
  score       FLOAT,
  min_price   FLOAT,
  is_delete   BOOLEAN DEFAULT '0',
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_concert_time`;
CREATE TABLE `ds_concert_time` (
  id        VARCHAR(32),
  parent_id VARCHAR(32),
  date      VARCHAR(255),
  time      VARCHAR(255),
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_face_values`;
CREATE TABLE `ds_face_values` (
  id        VARCHAR(32),
  parent_id VARCHAR(32),
  name      VARCHAR(100),
  price     FLOAT,
  count     INT,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_goods`;
CREATE TABLE `ds_goods` (
  id         VARCHAR(32),
  title      VARCHAR(100),
  poster     VARCHAR(100),
  image_list VARCHAR(100),
  short_desc VARCHAR(255),
  content    TEXT,
  price      DECIMAL(10, 2),
  count      INT,
  code       VARCHAR(100),
  on_sell    BOOLEAN DEFAULT '0',
  is_delete  BOOLEAN DEFAULT '0',
  created_on LONG,
  updated_on LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_seckill`;
CREATE TABLE `ds_seckill` (
  id          VARCHAR(32),
  title       VARCHAR(100),
  poster      VARCHAR(100),
  description VARCHAR(255),
  price       DECIMAL(10, 2),
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_shopping_cars`;
CREATE TABLE `ds_shopping_cars` (
  id          VARCHAR(32),
  customer_id VARCHAR(32),
  goods_id    VARCHAR(32),
  discounts   FLOAT,
  count       INT,
  step        INT(2),
  created_on  LONG,
  updated_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_purchase`;
CREATE TABLE `ds_purchase` (
  id           VARCHAR(32),
  sell_no      VARCHAR(16),
  customer_id  VARCHAR(32),
  item_id      VARCHAR(32),
  item_type    int,
  title        VARCHAR(100),
  detail       VARCHAR(300),
  price        DECIMAL(10, 2),
  count        INT,
  total        DECIMAL(10, 2),
  pay_type     VARCHAR(30),
  area_name    VARCHAR(200),
  address      VARCHAR(300),
  status       int,
  is_delete  BOOLEAN DEFAULT '0',
  created_on   LONG,
  updated_on   LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `ds_carousel`;
CREATE TABLE `ds_carousel` (
  id         VARCHAR(32),
  title      VARCHAR(200),
  image_id   VARCHAR(32),
  url        VARCHAR(100),
  is_active  BOOLEAN DEFAULT '0',
  is_delete  BOOLEAN DEFAULT '0',
  seq        INT(2),
  created_on LONG,
  updated_on LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_comments`;
CREATE TABLE `ds_comments` (
  id          VARCHAR(32),
  customer_id VARCHAR(32),
  concert_id  VARCHAR(32),
  comment     TEXT,
  status      int DEFAULT 0,
  score       FLOAT,
  created_on  LONG,
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_hot_search`;
CREATE TABLE `ds_hot_search` (
  id       VARCHAR(32),
  key_word VARCHAR(100),
  weight   INT,
  latest   INT(10),
  PRIMARY KEY (`id`)
)
  ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

DROP TABLE IF EXISTS `ds_class`;
CREATE TABLE `ds_class` (
    id varchar(32),
    name varchar(100),
    code VARCHAR(10),
    type BOOLEAN DEFAULT '0',
    seq INT,
    active BOOLEAN DEFAULT '1',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `ds_tag`;
CREATE TABLE `ds_tag` (
  code varchar(11),
  name varchar(200),
  PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
#
# DROP TABLE IF EXISTS `ds_`;
# CREATE TABLE `ds_` (
#     id varchar(32),
#
#     PRIMARY KEY (`id`)
# ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;